package by.airlanterns.web;

import by.airlanterns.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * User: Sergey
 * Date: 01.02.13
 * Time: 9:54
 * To change this template use File | Settings | File Templates.
 */
@Controller
@RequestMapping("cabinet")
public class CabinetController extends BaseController {

    @Autowired
    private OrderService orderService;


    @RequestMapping(method = RequestMethod.GET)
    private ModelAndView showCabinet(HttpServletRequest request, HttpServletResponse response) {
        Map<String, Object> model = getModel();
        model.put("orders", orderService.getOrdersByUser(getCurrentUser().getIdUser()));
        return new ModelAndView("cabinet", model);
    }


}
